package com.qf.tenement.tenement_user.utils;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    // 创建队列
    @Bean
    public Queue getQueue(){
        return new Queue("simpleQueue",true);
    }

    // 创建Fanout类型交换机
    @Bean
    public DirectExchange getExchange(){
        return new DirectExchange("simpleExchange",true,true);
    }

    // 将队列绑定到交换机
    @Bean
    public Binding simpleBinding(){
        return BindingBuilder.bind(getQueue()).to(getExchange()).with("simpleKey");
    }
}
